#ifndef QDC_V792_h
#define QDC_V792_h

#include "CAEN_module.h"

/*----------------------------------------------------------------------------
Integration of the QDC_V792 by CAEN to Dackel 20070404, Alex Kaplan
----------------------------------------------------------------------------*/

class QDC_V792 : public CAEN_module
{
 public:
		
    const static u_int16_t OUTPUT_BUFFER_LENGTH      =0x07cf;		
    const static u_int16_t IPED                       =0x1060;
    
	const static u_int32_t N_CHANNELS                 =32;
    const static u_int16_t PERKEO_CN                  =12;

    //-- bit patterns for output buffer data
    const static u_int32_t IS_INVALID_DATUM           =0x06000000;
	const static u_int32_t CHANNEL_MASK               =0x001f0000;
    const static u_int32_t CHANNEL_SHIFT              =16;
    const static u_int32_t VALUE_MASK                 =0x00000fff;
    const static u_int32_t VALUE_SHIFT                =0;
    //constructor
    QDC_V792( int handle, u_int32_t addr );
    
	virtual u_int32_t GetNChannels();
	
	// Read a single event to a DACKEL EventStruct
    // ch0 -> adc00, ch1 -> adc01, ch2 -> adc02
    // ch3 -> adc10, ch4 -> adc11, ch5 -> adc12
    // ch6 -> adc20, ch7 -> adc21, ch8 -> adc22
    // ch9 -> adc30, ch10-> adc31, ch11-> adc32
    // returns the event coutner for the event
    u_int32_t ReadEvent(EventStruct *ev);
    u_int32_t ReadEventFast(EventStruct *ev);
    u_int32_t ReadEvents(EventStruct *ev,u_int32_t num);
};

#endif
